using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SBPweb.Presentation.Windows.Forms.Controls
{
	public partial class LayoutSelectForm : SBPweb.Controls.Windows.Common.Form
	{

		public LayoutSelectForm()
		{
			InitializeComponent();
		}

		void btOk_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.OK;
			Close();
		}

		private void btnCancel_Click(object sender, EventArgs e)
		{
			DialogResult = DialogResult.Cancel;
			Close();
		}

		public string Execute(List<string> items, string selectedItem)
		{
			cbItems.Items.Clear();
			cbItems.Items.AddRange(items.ToArray());
			cbItems.SelectedIndex = string.IsNullOrEmpty(selectedItem) ? -1 : cbItems.Items.IndexOf(selectedItem);
			if (this.ShowDialog() == DialogResult.OK)
			{
				return (string)cbItems.SelectedItem;
			}
			return null;
		}
	}
}